|
|
 |
|
|
|
|
' Display the text. CurrentX = 240
CurrentY = 30
Print txt
' Reselect the old font. newfont = SelectObject(hdc, oldfont)
' Delete the new font to free resources. DeleteObject newfont
End Sub |
|
|
|
|
|
|
|
|
Example program MkFonts, shown in Figure 4.7, uses CreateFont to make and display several different versions of the Times New Roman font. |
|
|
|
|
|
|
|
|
In the column on the left, the program displays text in weights ranging from 0 to 900. On the computer that produced the output shown in Figure 4.7, this font has only FW_NORMAL, FW_DEMIBOLD, and FW_BOLD values. All the other font weights are mapped to one of these. |
|
|
|
|
|
|
|
|
In the second column, MkFonts draws characters that are five points wide and have heights ranging from 15 to 55. The third column shows fonts with height 15 and widths ranging from 3 to 18. |
|
|
|
|
|
|
|
|
The program then displays 10 strings with different escapements starting at the same point. The strings begin with several space characters, so they do not overlap. |
|
|
|
|
|
|
|
|
With a little extra work, you can display text that follows a curve. The CurveText subroutine, shown in the following code, uses CreateFont to display text along a path defined by a series of points. |
|
|
|
|
|
|
|
|
Figure 4.7
Advanced text display. |
|
|
|
|
|